<template>
  <div class="box">
    <header>可视化面板-Echarts</header>
    <section class="main-box flex">
      <div class="column">
        <div class="panel bar">
          <h2>柱形图-就业行业</h2>
          <div class="chart flex j-c a-c">
            <left-top-echart :bar="barChart"> </left-top-echart>
          </div>
          <div class="panel-footer"></div>
        </div>
        <div class="panel line">
          <h2>
            曲线图-新增就业
            <a @click="triggerYear(2020)" href="javascript:;">2020</a>
            <span href="javascript:;">/</span>
            <a @click="triggerYear(2021)" href="javascript:;">2021</a>
          </h2>
          <div class="chart">
            <left-mid-echart :year="year" :bar="line"></left-mid-echart>
          </div>
          <div class="panel-footer"></div>
        </div>
        <div class="panel pie">
          <h2>饼形图-年龄分布</h2>
          <div class="chart">
            <left-bot-echart :bar="pie"></left-bot-echart>
          </div>
          <div class="panel-footer"></div>
        </div>
      </div>
      <div class="column">
        <!-- no模块 -->
        <div class="no">
          <div class="no-hd">
            <ul class="flex">
              <li>1230265</li>
              <li>1049878</li>
            </ul>
          </div>
          <div class="no-bd">
            <ul class="flex">
              <li>前端需求人数</li>
              <li>市场供应人数</li>
            </ul>
          </div>
        </div>
        <!-- 地图模块 -->
        <div class="map">
          <div class="map1"></div>
          <div class="map2"></div>
          <div class="map3"></div>
          <div class="chart">
            <middle-echart :bar="middle"></middle-echart>
          </div>
        </div>
      </div>
      <div class="column">
        <div class="panel bar2">
          <h2>柱形图-技术需求</h2>
          <div class="chart">
            <right-top-echart :bar="bar2Chart"></right-top-echart>
          </div>
          <div class="panel-footer"></div>
        </div>
        <div class="panel line2">
          <h2>曲线图-男女比例</h2>
          <div class="chart">
            <right-mid-echart :bar="line2"></right-mid-echart>
          </div>
          <div class="panel-footer"></div>
        </div>
        <div class="panel pie2">
          <h2>饼形图-地区就业</h2>
          <div class="chart">
            <right-bot-echart :bar="pie2"></right-bot-echart>
          </div>
          <div class="panel-footer"></div>
        </div>
      </div>
    </section>
  </div>
</template>

<script>
import LeftTopEchart from "views/childEcharts/LeftTopEchart";
import RightTopEchart from "views/childEcharts/RightTopEchart";
import LeftMidEchart from "views/childEcharts/LeftMidEchart";
import RightMidEchart from "views/childEcharts/RightMidEchart";
import LeftBotEchart from "views/childEcharts/LeftBotEchart";
import RightBotEchart from "views/childEcharts/RightBotEchart";
import MiddleEchart from "views/childEcharts/MiddleEchart";
export default {
  name: "Home",
  components: {
    LeftTopEchart,
    RightTopEchart,
    LeftMidEchart,
    RightMidEchart,
    LeftBotEchart,
    RightBotEchart,
    MiddleEchart,
  },
  data() {
    return {
      barChart: "",
      bar2Chart: "",
      line: "",
      line2: "",
      pie: "",
      pie2: "",
      middle: "",
      year: "",
      eventData: {
        year: 2020,
        month: [1, 2, 3, 4],
        season: [1, 2, 3, 4],
      },
    };
  },
  mounted() {
    this.barChart = document.querySelector(".bar .chart");
    this.bar2Chart = document.querySelector(".bar2 .chart");
    this.line = document.querySelector(".line .chart");
    this.line2 = document.querySelector(".line2 .chart");
    this.pie = document.querySelector(".pie .chart");
    this.pie2 = document.querySelector(".pie2 .chart");
    this.middle = document.querySelector(".map .chart");

    this.dataArr = Object.entries(this.eventData);
    console.log(this.dataArr.slice(0, 2));
    this.dataArr = this.dataArr.slice(0, 2);
    this.dataArr = Object.fromEntries(this.dataArr);
    // this.dataArr.forEach((r, i) => {
    //   console.log(r[1]);
    // });
    console.log(this.eventData.valueOf() === this.eventData);
    console.log(this.eventData);
  },
  methods: {
    triggerYear(val) {
      this.year = val;
    },
  },
};
</script>
<style lang="scss" scoped>
* {
  margin: 0;
  padding: 0;
  overflow: hidden;
}

.map {
  position: relative;
  height: 10.125rem;
  .chart {
    position: absolute;
    width: 100%;
    height: 10.15rem;
    top: 0;
    left: 0;
  }
  .map3 {
    position: absolute;
    width: 7.075rem;
    height: 7.075rem;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: url("~assets/img/jt.png") no-repeat;
    background-size: cover;
    animation: rotate2 15s infinite;
    opacity: 0.6;
  }
  .map1 {
    position: absolute;
    width: 6.475rem;
    height: 6.475rem;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: url("~assets/img/map.png") no-repeat;
    background-size: cover;
    // animation: rotate1 15s infinite;
  }
  .map2 {
    position: absolute;
    width: 8.0375rem;
    height: 8.0375rem;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: url("~assets/img/lbx.png") no-repeat;
    background-size: cover;
    animation: rotate1 15s infinite;
    opacity: 0.6;
  }
  @keyframes rotate1 {
    from {
      transform: translate(-50%, -50%) rotate(0deg);
    }

    to {
      transform: translate(-50%, -50%) rotate(360deg);
    }
  }
  @keyframes rotate2 {
    from {
      transform: translate(-50%, -50%) rotate(0deg);
    }

    to {
      transform: translate(-50%, -50%) rotate(-360deg);
    }
  }
}
.no {
  background: rgba(101, 132, 226, 0.1);
  padding: 0.1875rem;
  .no-hd {
    position: relative;
    ul {
      border: 1px solid rgba(25, 186, 139, 0.17);
      li {
        position: relative;
        padding: 0.125rem 0;
        text-align: center;
        flex: 1;
        font-size: 0.875rem;
        color: #ffeb7b;
        font-weight: 600;
        font-family: "LCD";
      }
      &::after {
        content: "";
        position: absolute;
        top: 25%;
        right: 50%;
        height: 50%;
        width: 1px;
        background: rgba(255, 255, 255, 0.2);
      }
    }

    &::before {
      position: absolute;
      content: "";
      top: 0;
      left: 0;
      width: 30px;
      height: 10px;
      border-left: 2px solid #02a6b5;
      border-top: 2px solid #02a6b5;
    }
    &::after {
      position: absolute;
      content: "";
      bottom: 0;
      right: 0;
      width: 30px;
      height: 10px;
      border-right: 2px solid #02a6b5;
      border-bottom: 2px solid #02a6b5;
    }
  }
  .no-bd {
    ul {
      li {
        flex: 1;
        text-align: center;
        font-size: 0.225rem;
        height: 0.5rem;
        color: rgba(255, 255, 255, 0.7);
        padding-top: 0.125rem;
        line-height: 0.5rem;
      }
    }
  }
}
.box {
  background: url("~assets/img/bg.jpg") no-repeat top center;
  background-size: cover;
  line-height: 1.15;
  header {
    color: #fff;
    font-size: 36px;
    font-family: "LED";
    text-shadow: rgb(26, 26, 26) 10px 10px 5px;
    text-align: center;
    line-height: 1.25rem;
    height: 1rem;
    background: url("~assets/img/head_bg.png") no-repeat top center;
    background-size: cover;
  }
  .main-box {
    min-width: 1024px;
    max-width: 1920px;
    margin: 0 auto;
    padding: 0.125rem 0.125rem 0;
    .column {
      flex: 3;
      color: rgb(140, 139, 139);
      &:nth-child(2) {
        flex: 5;
        margin: 0.1875rem 0;
        overflow: hidden;
      }
    }
    .panel {
      position: relative;
      bottom: 0;
      left: 0;
      background-color: #fff;
      height: 3.875rem;
      padding: 0 0.125rem;
      border: 1px solid rgba(25, 186, 139, 0.17);
      background: url("~assets/img/line(1).png") rgba(255, 255, 255, 0.03);
      margin: 0.1875rem;
      a {
        color: #fff;
        text-decoration: underline;
        font-size: 14px;
        font-weight: 300;
      }
      &::before {
        position: absolute;
        top: 0;
        left: 0;
        width: 10px;
        height: 10px;
        border-left: 2px solid #02a6b5;
        border-top: 2px solid #02a6b5;
        content: "";
      }
      &::after {
        position: absolute;
        top: 0;
        right: 0;
        width: 10px;
        height: 10px;
        border-right: 2px solid #02a6b5;
        border-top: 2px solid #02a6b5;
        content: "";
      }
      h2 {
        font-size: 0.25rem;
        font-weight: 400;
        line-height: 0.6rem;
        height: 0.6rem;
        color: #fff;
        text-align: center;
      }
      .chart {
        height: 3rem;
        // background-color: rgb(138, 138, 138);
      }
      .panel-footer {
        position: absolute;
        bottom: 0;
        left: 0;
        height: 0.125rem;
        width: 100%;
        &::before {
          position: absolute;
          left: 0;
          bottom: 0;
          width: 10px;
          height: 10px;
          border-left: 2px solid #02a6b5;
          border-bottom: 2px solid #02a6b5;
          content: "";
        }
        &::after {
          position: absolute;
          right: 0;
          bottom: 0;
          width: 10px;
          height: 10px;
          border-right: 2px solid #02a6b5;
          border-bottom: 2px solid #02a6b5;
          content: "";
        }
      }
    }
  }
}
/* 约束屏幕尺寸 */
@media screen and (max-width: 1024px) {
  html {
    font-size: 42px !important;
  }
}

@media screen and (min-width: 1920px) {
  html {
    font-size: 80px !important;
  }
}
</style>
